from google.appengine.ext import db
from google.appengine.api import mail
from settings import NANNYCENTRAL_MAIL_FROM, NANNYCENTRAL_MAIL_WELCOME_BODY, NANNYCENTRAL_MAIL_WELCOME_SUBJECT

class Nanny( db.Model ):
    email                       = db.EmailProperty() 
    FirstName                   = db.TextProperty()
    LastName                    = db.TextProperty()
    Gender                      = db.BooleanProperty()
    BirthDate                   = db.DateTimeProperty()
    PostalAddress               = db.PostalAddressProperty()
    PrimayPhone                 = db.PhoneNumberProperty()
    SecondaryPhone              = db.PhoneNumberProperty()
    AllowUserToSeePhone         = db.BooleanProperty()
    Nationality                 = db.TextProperty()
    HaveChildren                = db.BooleanProperty()
    ChildrenAccompaignAges      = db.TextProperty()
    Active                      = db.BooleanProperty( default = False )
    

    def send_welcome_mail(self):    
        mail.send_mail( NANNYCENTRAL_MAIL_FROM, \
                        to=self.email,\
                        subject=NANNYCENTRAL_MAIL_WELCOME_SUBJECT,\
                        body=NANNYCENTRAL_MAIL_WELCOME_BODY )
        
    
class Toy( db.Model ):
    name                        = db.TextProperty()
    description                 = db.TextProperty()
    pro                         = db.TextProperty()
    con                         = db.TextProperty()
    longevity                   = db.RatingProperty()
    cost                        = db.RatingProperty()
    buyAt                       = db.LinkProperty
    photos                      = db.LinkProperty
    related                     = db.ListProperty( db.Key ) # list of other object
    
    def getRandomToy(self):
        pass
    
    
    
class Recipe( db.Model ):
    title                       = db.TextProperty()
    
    
class Item( db.Model ):
    Name                        = db.TextProperty()
    InsertDate                  = db.DateTimeProperty()
    Got                         = db.BooleanProperty()
    GotDate                     = db.DateTimeProperty()
    GotFrom                     = db.TextProperty()
    Provider                    = db.LinkProperty()
    Rating                      = db.RatingProperty()
    
class Contact( db.Model ):
    FirstName                   = db.TextProperty()
    LastName                    = db.TextProperty()
    Rule                        = db.TextProperty()
    Email                       = db.EmailProperty()
    
class Child( db.Model ):
    FirstName                   = db.TextProperty()
    LastName                    = db.TextProperty()
    BirthDate                   = db.DateTimeProperty()
    Gender                      = db.BooleanProperty()
    WishList                    = db.ListProperty( db.Key )  
    ContactList                 = db.ListProperty( db.Key )

#
# The facebook user.
#
class FBUser(db.Model):
    fbid = db.StringProperty(required=True)
    created = db.DateTimeProperty(auto_now_add=True)
    updated = db.DateTimeProperty(auto_now=True)
    name = db.StringProperty(required=True)
    profile_url = db.StringProperty(required=True)
    access_token = db.StringProperty(required=True)    
            